package main

import (
	"fmt"
	"strings"
)

// Author : CSR丶WARRIOR
// Time ： 2020/10/22  11:29
// TOOLS : GoLand
// FILENAME : TestStringOne.go
// STATEMENT:

func main() {
	//testContains()
	//testJoin()
	//textIndex()
	//testRepeat()
	//testReplace()
	testSplit()
}

func testContains() {
	var str string = "what the fuck?"
	var substr string = "what"
	isContains := strings.Contains(str, substr)
	fmt.Println(isContains) //true
}

func testJoin() {
	var s1 string = "what"
	var s2 string = "the"
	var s3 string = "fuck"
	var strSlice = make([]string, 0)
	strSlice = append(strSlice, s1, s2, s3)
	newStr := strings.Join(strSlice, " ")
	fmt.Println(newStr) //what the fuck
}
func textIndex() {
	var str string = "what the fuck what ?"
	var substr string = "what"
	pos := strings.Index(str, substr)
	fmt.Println(pos) //0
}
func testRepeat() {
	strs := strings.Repeat("hello ", 3)
	fmt.Println(strs)
	//hello hello hello
}
func testReplace() {
	var str string = "what the fuck what ?"
	newStr := strings.Replace(str, "fuck", "hell", -1)
	fmt.Println(newStr) //what the hell what ?
}
func testSplit() {
	var str string = "what the fuck?"
	split := strings.Split(str, " ")
	fmt.Printf("%T\n", split) //[]string
	fmt.Println(split)        //[what the fuck?] ,字符串切片
}
